package com.lemon.controller;

import com.lemon.service.AiService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ai")
@RequiredArgsConstructor
public class AiController {
    private final AiService aiService;

    /**
     * 默认对话接口
     */
    @GetMapping(value = "/chat")
    public String chat(String question, String sessionId) {
        return aiService.chat(question, sessionId);
    }

    /**
     * 支持指定角色和模型的对话接口
     *
     * @param question 用户问题
     * @param sessionId 会话ID
     * @param role 角色类型 (default, customer_service, data_analyst)
     * @param model 模型类型 (qwen-plus, qwen-turbo, gpt-3.5-turbo, gpt-4)
     * @return AI回答
     */
    @PostMapping(value = "/chat/advanced")
    public String chatWithRoleAndModel(@RequestParam String question,
                                       @RequestParam String sessionId,
                                       @RequestParam(required = false, defaultValue = "default") String role,
                                       @RequestParam(required = false, defaultValue = "qwen-plus") String model) {
        return aiService.chatWithRoleAndModel(question, sessionId, role, model);
    }

    /**
     * 获取可用角色列表
     */
    @GetMapping(value = "/roles")
    public String[] getAvailableRoles() {
        return new String[]{"default", "customer_service", "data_analyst"};
    }

    /**
     * 获取可用模型列表
     */
    @GetMapping(value = "/models")
    public String[] getAvailableModels() {
        // 提供阿里云Qwen模型和OpenAI模型
        return new String[]{"qwen-plus", "qwen-turbo", "gpt-3.5-turbo", "gpt-4"};
    }
}
